package cn.zhentao.controller;

import cn.zhentao.pojo.Doctor;
import cn.zhentao.pojo.User;
import cn.zhentao.service.DoctorService;
import cn.zhentao.vo.ZhVo;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@RestController
@RequestMapping("/doc")
public class DoctorController {
@Autowired
    private DoctorService doctorService;
//=====cx
@GetMapping("/finda")
public PageInfo<Doctor> finda(@RequestParam("pageNum")Integer pageNum, @RequestParam("pageSize")Integer pageSize,@RequestParam String dname){
    PageHelper.startPage(pageNum,pageSize);
    List<Doctor> findd = doctorService.findd(dname);
    PageInfo<Doctor> doctorPageInfo = new PageInfo<>(findd);
    return doctorPageInfo;
}
//=====tj
    @PostMapping("/addd")
    public void addd(@RequestBody Doctor doctor){
        doctorService.addd(doctor);
    }
//=====xg
    @PostMapping("/updated")
    public int updated(@RequestBody Doctor doctor){
        doctorService.updated(doctor);
    return 1;
    }
//=====sc
    @PostMapping("/del")
    public int del(@RequestBody Integer [] did){
        int del = doctorService.del(did);
        return del;
    }
}
